<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
    <!-- 通过点击事件改变了type的值，从而改变了页面元素的渲染 -->
    <div id="app">
        <p v-if="message">这是一个段落标签</p>
        <button @click="A">click me</button>
        <div v-if="type==1" style="color: red">A</div>
        <div v-else-if="type==2" style="color: blue">B</div>
        <div v-else-if="type==3" style="color: purple">C</div>
        <div v-else>D</div>
        <button @click="B">click me</button>
    </div>
    <script>
          // 创建Vue的对象
          let vm = new Vue({
              el:"#app",
              data:{
                  message:true,
                  type:0
                },
                //在 'methods'对象中定义方法
                methods: {
                   A:function(){
                       this.message = false;
                   },
                   B(){
                       if(this.type>5){
                           this.type = 1;
                       }else {
                           this.type++;
                       }
                   }
                }
          })
    </script>
</body>
</html>